<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

	<ui:composition 
	  xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      template="/view/templates/templateLayout.xhtml">
      
      <ui:define name="conteudo">      	
  	  <link rel="stylesheet" type="text/css" href="./estilos.css"/>
  	  
<h:form id="formManterContaPagar" prependId="false"> 
	<p:panel id="panelManterContaPagar" header="Manter ContaPagar" style="margin-bottom:20px; ">  
	<f:facet name="header">
		<h:outputText value="Cadastrar Nova Conta a Pagar" styleClass="outputTextTitulo"/>
	</f:facet>
 	<p:messages id="messagesManterContaPagar" autoUpdate="true" closable="true" /> 
 		<h:panelGroup>
    	<h:panelGrid id="pgContaPagar" columns="5" style="margin-top:20px; margin-right:10%;">  
            <h:outputLabel value="Código" styleClass="outputLabel"/>  
            <h:outputLabel value="Descrição*" styleClass="outputLabel"/>    
            <h:outputLabel value="Data Vencimento*" styleClass="outputLabel"/> 
            <h:outputLabel value="Data de Pagamento" styleClass="outputLabel"/>   
            <h:outputLabel value="Status" styleClass="outputLabel"/>           
            <p:inputText value="#{contaPagarBean.contaPagar.idContaPagar}" styleClass="inputId" disabled="true"/>  
            <p:inputText value="#{contaPagarBean.contaPagar.descricao}" styleClass="inputDescricao" maxlength="40" disabled="#{contaPagarBean.disableInputSave()}"
            				required="true" requiredMessage="Preencha a Descrição."/> 
            <p:inputMask mask="99/99/9999" value="#{contaPagarBean.contaPagar.dtVencimento}" styleClass="inputData" disabled="#{contaPagarBean.disableInput()}">
            	<p:ajax listener="#{contaPagarBean.onChangeDate}" />
            	<f:convertDateTime dateStyle="medium"/>
            </p:inputMask>	
            <p:inputMask mask="99/99/9999" value="#{contaPagarBean.contaPagar.dtPagamento}" styleClass="inputData" disabled="#{contaPagarBean.disableInput()}">
            	<p:ajax listener="#{contaPagarBean.onChangeDate}" />
            	<f:convertDateTime dateStyle="medium"/>
            </p:inputMask>
             <p:inputText value="#{contaPagarBean.contaPagar.status}" styleClass="inputData" disabled="true"/>   			
        </h:panelGrid> 
        </h:panelGroup>
        <h:panelGrid id="pgFornecedor" columns="3" style="margin-right:10%;">  
            <h:outputLabel value="Código*" styleClass="outputLabel"/>  
            <h:outputLabel value="Fornecedor*" styleClass="outputLabel"/>     
            <h:outputLabel  />           
            <p:inputText value="#{contaPagarBean.contaPagar.fornecedor.idFornecedor}" styleClass="inputId" disabled="#{contaPagarBean.disableInputSave()}">
            	<p:ajax  listener="#{contaPagarBean.onChangeFornecedor}" update="pgFornecedor" />
            	<p:ajax  listener="#{contaPagarBean.onChangeFornecedorNull}" update="pgFornecedor" />
            </p:inputText>  
  			<p:inputText  value="#{contaPagarBean.contaPagar.fornecedor.razaoSocial}" maxlength="40" styleClass="inputDescricao" disabled="#{contaPagarBean.disableInputSave()}"> 
  				<p:ajax  listener="#{contaPagarBean.onChangeFornecedorNull}" update="pgFornecedor" />
			</p:inputText> 
  			<p:commandButton icon="ui-icon-search" action="#{contaPagarBean.openDialogConsultarFornecedor}"  immediate="true" disabled="#{contaPagarBean.disableInputSave()}"/>
        </h:panelGrid>   
        <h:panelGrid id="pgTotal" columns="6" style="margin-right:10%;">  
        	<h:outputLabel value="Valor(R$)*" styleClass="outputLabel"/>	
        	<h:outputLabel value="Juros(%)" styleClass="outputLabel"/>
        	<h:outputLabel value="Multa(R$)" styleClass="outputLabel"/>
        	<h:outputLabel value="Desconto(%)" styleClass="outputLabel"/>
        	<h:outputLabel value="Desconto(R$)" styleClass="outputLabel"/>		
            <h:outputLabel value="Total(R$)" styleClass="outputLabel"/> 
			<p:inputText value="#{contaPagarBean.contaPagar.valor}" styleClass="inputData" maxlength="7" disabled="#{contaPagarBean.disableInput()}"
								required="true" requiredMessage="Preencha o Valor.">
				<f:convertNumber type="number"/>
				<p:ajax  listener="#{contaPagarBean.onChangeValor}" update="inputValorTotal" />
			</p:inputText>    
            <p:inputText id="inputJuros" value="#{contaPagarBean.contaPagar.juros}" styleClass="inputData" maxlength="5" disabled="#{contaPagarBean.disableJuros()}">
            	<f:convertNumber type="number"/>
            	<p:ajax  listener="#{contaPagarBean.calculaJuros}" update="inputValorTotal" />
            	<p:ajax listener="#{contaPagarBean.onChangeJuros}" update="inputDescontoReal, inputDesconto, inputJuros, inputValorTotal"/>
           	</p:inputText>
            <p:inputText value="#{contaPagarBean.contaPagar.multa}" styleClass="inputData" maxlength="5" disabled="#{contaPagarBean.disableInput()}"> 
            	<f:convertNumber type="number"/>          	
            	<p:ajax  listener="#{contaPagarBean.calculaMulta}" update="inputValorTotal" />
           	</p:inputText> 
            <p:inputText id="inputDesconto" value="#{contaPagarBean.contaPagar.desconto}" styleClass="inputData" maxlength="5" disabled="#{contaPagarBean.disableDesconto()}">
            	<f:convertNumber type="number"/>           	
            	<p:ajax  listener="#{contaPagarBean.calculaDesconto}" update="inputValorTotal" />
            	<p:ajax listener="#{contaPagarBean.onChangeDesconto}" update="inputDescontoReal, inputDesconto, inputJuros, inputValorTotal"/>
           	</p:inputText> 
            <p:inputText id="inputDescontoReal" value="#{contaPagarBean.contaPagar.descontoReal}" styleClass="inputData" maxlength="7" disabled="#{contaPagarBean.disableDescontoReal()}">  
            	<f:convertNumber type="number"/>         	
            	<p:ajax  listener="#{contaPagarBean.calculaDescontoReal}" update="inputValorTotal" />
            	<p:ajax listener="#{contaPagarBean.onChangeDescontoReal}" update="inputDescontoReal, inputDesconto, inputJuros, inputValorTotal"/>
           	</p:inputText>          
            <p:inputText id="inputValorTotal" value="#{contaPagarBean.contaPagar.valorTotal}" styleClass="inputData" disabled="true" >
            	<f:convertNumber type="number"/>
            </p:inputText>	           
        </h:panelGrid>   	
    </p:panel>  
    <p:commandButton value="Salvar" actionListener="#{contaPagarBean.saveContaPagar}" update="panelManterContaPagar, messagesManterContaPagar, pgTotal" style="margin-right:20px; margin-left:10px;" disabled="#{contaPagarBean.disableInputSave()}"/> 
	<p:commandButton value="Voltar" action="#{contaPagarBean.consultarContaPagar}" immediate="true" style="margin-right:20px;" /> 
</h:form> 
<ui:include src="/view/contaPagar/dialogConsultarFornecedor.xhtml" /> 	
</ui:define>
</ui:composition>
